package com.hl.toolkit.framework.core.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * 
 * 系统上下文工具类
 * 
 * @author  vic
 * @version  [1.0, 2017年9月24日]
 */
public class ContextHolderUtil {
	
	
	/** 
	 * spring mvc 下获取request
	 * @return HttpServletRequest
	 */
	public static HttpServletRequest getRequest(){
		return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
	}
	
	/** 
	 * spring mvc 下获取session
	 * @return HttpSession
	 */
	public static HttpSession getSession(){
		return getRequest().getSession();
	}
			
}
